﻿using System;
using System.Threading;
using System.Threading.Tasks;
namespace Athena.xUnit.ProxyGenerater
{
    using Message;
    using Runtime.Client;

    public class VirtualRpcInvokeService : IRpcInvokeService
    {
        private Func<RpcInvokeContext, object> _invokeResultCallBack;
        public VirtualRpcInvokeService(Func<RpcInvokeContext, object> invokeResultCallBack)
        {
            _invokeResultCallBack = invokeResultCallBack;
        }

        public Task<RpcInvokeResultMessage> InvokeAsync(RpcInvokeContext rpcInvokeContext)
        {
            return Task.FromResult(new RpcInvokeResultMessage()
            {
                Code = 200,
                CorrelationId = Guid.NewGuid().ToString(),
                Message = string.Empty,
                Result = _invokeResultCallBack(rpcInvokeContext),
            });
        }

        public Task<RpcInvokeResultMessage> InvokeAsync(RpcInvokeContext rpcInvokeContext, CancellationToken cancellationToken)
        {
            return Task.FromResult(new RpcInvokeResultMessage()
            {
                Code = 200,
                CorrelationId = Guid.NewGuid().ToString(),
                Message = string.Empty,
                Result = _invokeResultCallBack(rpcInvokeContext)
            });
        }
    }


    public class VirtualModel
    {
    }
}
